package com.ruoyi.ai.controller.inner;

import com.ruoyi.ai.factory.ModelChatService;
import com.ruoyi.ai.factory.ModelChatStrategyFactory;
import com.ruoyi.common.annotation.AllowedIp;
import com.ruoyi.common.core.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/inner/ai")
public class AIController {

    /**
     * 获取一次对话
     * 暂时限制只能本机ip访问
     */
    @AllowedIp(value = {"127.0.0.1"})
    @GetMapping("/chatOnce")
    public R<String> chatOnce(@RequestParam String content) {
        ModelChatService modelChatService = ModelChatStrategyFactory.getEnableMfg();
        String res = modelChatService.chatStreamOnce(content);
        return R.ok("",res);
    }
}
